#-*- coding:utf-8 -*-
'''
author: minvan
date:2021/3/1
'''
import requests
import logging
import sys
import json

class OrderListen(object):
    def __init__(self):
        self.ListenrCookie = []
        self.DeliverCookie = []
        self.AppUrl = ''
        self.P = ''
        self.DestLocation = ''

    def MakeSendOrder(self):
        '''

        :param User: 创建派单的司机 0 or 1
        :return: OrderNo 订单号
        '''
        cookies = self.DeliverCookie
        url = self.AppUrl + "/webapi/app/order/deliver/submit"
        headers = {"Cookie": cookies}
        data = {}
        data['contactPhone'] = "18571015163"
        data['app'] = self.App
        data['p'] = self.P
        data['destLocation'] = self.destLocation
        data['srcLocation'] = self.srcLocation
        data['confirmInfo'] = "1"
        try:
            Resp = requests.post(url=url, json=data, headers=headers)
            OrderNo = json.loads(Resp.content.decode())['result']['orderNo']
            logging.info(sys._getframe(0).f_code.co_name+" 已派单，派单号： "+OrderNo)
        except:
            OrderNo = None
            logging.warning(sys._getframe(0).f_code.co_name+"派单出现异常！")
        return OrderNo

    def OrderListen(self):
        Url = ''
        Cookie = ''


if __name__ == '__main__':
    while True:
        OrderListen().MakeSendOrder()

# a,b = 1,2
#
# if (b>a>0) and (a+b=3) :
#     print("good")
# else:
#     pass